﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LazyAsset.cs" company="Anton Frattaroli">
//   Copyright (c) Anton Frattaroli. All rights reserved.
// </copyright>
// <summary>
//   Defines the LazyAsset class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Lidocaine.Data
{
    using Lidocaine.BusinessObjects;

    /// <summary>
    /// Defines the LazyAsset class.
    /// </summary>
    public class LazyAsset : BusinessObjects.Asset
    {
        /// <summary>
        /// Gets or sets the file's filetype.
        /// </summary>
        public override BusinessObjects.FileType FileType
        {
            get
            {
                if (base.FileType == null && this.FileTypeId != 0)
                {
                    base.FileType = Data.FileType.Select(this.FileTypeId);
                }

                return base.FileType;
            }

            set
            {
                base.FileType = value;
                if (value != null)
                {
                    this.FileTypeId = value.Id;
                }
                else
                {
                    this.FileTypeId = 0;
                }
            }
        }
    }
}
